home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / DATABASE / OBJ1_2.ZIP;1 / C_STACK.TXT < prev    next >
Encoding:
Text File  |  1992-12-22  |  1.9 KB  |  62 lines

  1. '
  2. 'Class description:
  3. '
  4. !short:Stack class structure
  5. Class Stack:
  6. ~~~~~~~~~~~~~
  7. Stack is defined as an object.
  8.  
  9.  
  10. Common use:
  11. ~~~~~~~~~~~~~~~~~
  12. LOCAL OBJECT Stack OF Stack
  13. Stack:Push(...)  //can be used repeatedly
  14. ...
  15. x:=Stack:Pop()   //can be repeated
  16.  
  17. Source code of class Stack is in C_Stack.prg
  18.  
  19. !seealso: c_menu.ngo:Menu c_color.ngo:Color ob_class.ngo:"Class hierarchy"
  20.  
  21. !short:~~~~~~~~~~~~~~~~~~~~~~~
  22. !short:create class Stack
  23. !short:  export:
  24. !short:  var Data    //{}
  25. ^BStack:Data^N: private: array
  26.   Array which data is filled by Push(val) method and retrieved by
  27.   Pop() method.
  28.  
  29. !short:  method New=StackNew           //o:New() --> self
  30. ^BStack:New()^N: public: return self
  31.   Object is filled with default values.
  32.  
  33. !short:  method Init=StackInit         //o:Init() --> true
  34. ^BStack:Init()^N: public: return true
  35.   The stack is initialised, i.e. the instvar variable is set to {}
  36.   (empty array).
  37.  
  38. !short:  method Push=StackPush         //o:Push(val) --> xVal
  39. ^BStack:Push(xVal)^N: public: return xVal
  40.   The value xVal is stored on top of the stack.
  41.  
  42. !short:  method Pop=StackPop           //o:Pop() --> xVal
  43. ^BStack:Pop()^N: public: return xVal
  44.   The last stored value is retrieved as result and stack is lowered by one.
  45.  
  46. !short:  method Top=StackTop           //o:Top() --> xVal
  47. ^BStack:Top()^N: public: return xVal
  48.   The last stored value is returned, no stack size change.
  49.  
  50. !short:  method IsEmpty=StackIsEmpty   //o:IsEmpty() --> true/false
  51. ^BStack:IsEmpty()^N: public: return true/false
  52.   If empty true is returned, else false is returned.
  53.  
  54. !short:  method Done=StackDone         //o:Done() --> true
  55. ^BStack:Done()^N: public: return true
  56.   Nothing to do because the memory becomes free when the object is destroyed.
  57.   When the object of class Stack is destroyed, its instvar variable
  58.   Stack:data is also destroyed.
  59.  
  60. !short:  endclass
  61.  
  62.